package com.egene.zh.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.text.TextUtils;

public class CheckUtil {
	private final static Pattern PHONE_PATTERN = Pattern.compile("[1]{1}[3,4,5,6,7,8]{1}[0-9]{9}");

	public static boolean checkPW(String pwd){
		if(TextUtils.isEmpty(pwd)){
			MToast.show("密码为空");
			return false;
		}
		if (pwd.length() < 6 || pwd.length() > 12) {
			MToast.show("请输入6-12位密码");
			return false;
		}
		return true;
	}
	
	
	public static boolean checkPhone(String phone){
		Matcher m = PHONE_PATTERN.matcher(phone);
		if(TextUtils.isEmpty(phone)){
			MToast.show("手机号码不能为空");
			return false;
		}
		if (phone.length() != 11) {
			MToast.show("请输入11位手机号码");
			return false;
		}
		if(!m.matches()){
			MToast.show("手机号码格式错误");
			return false;
		}
		return true;
	}

	public static boolean checkPhone(String phone, String errorText){
		Matcher m = PHONE_PATTERN.matcher(phone);
		if(TextUtils.isEmpty(phone)){
			MToast.show("手机号码不能为空");
			return false;
		}
		if (phone.length() != 11) {
			MToast.show("请输入11位手机号码");
			return false;
		}
		if(!m.matches()){
			MToast.show("手机号码格式错误");
			return false;
		}
		return true;
	}
}
